package xin.tomdonkey.chat.udp.util;

/**
 * @author guolinyuan
 */
public class ByteUtils
{
    public static byte[] unsignedShortToByte2(int s)
    {
        byte[] targets = new byte[2];
        targets[0] = (byte) (s >> 8 & 0xFF);
        targets[1] = (byte) (s & 0xFF);
        return targets;
    }

    public static int byte2ToUnsignedShort(byte[] bytes, int off)
    {
        int high = bytes[off];
        int low = bytes[off + 1];
        return (high << 8 & 0xFF00) | (low & 0xFF);
    }
}
